package com.evil.kingdom.pojo.entity.person.skill;

import com.evil.kingdom.pojo.entity.base.Fight;
import com.evil.common.mongo.entity.SingleName;
import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Objects;

/**
 * 技能
 *
 * @author liyang
 * @date 2024-05-23 14:41
 */
@Getter
@Setter
@Document
public class Skill extends Fight implements SingleName {

    /**
     * 名称
     */
    @Id
    @NotBlank(message = "名称不能为空")
    private String name;

    @Override
    public String getEntityName() {
        return "技能";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Skill skill = (Skill) o;

        return Objects.equals(name, skill.name);
    }

    @Override
    public int hashCode() {
        return name != null ? name.hashCode() : 0;
    }
}
